#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author： 青城子
# datetime： 2021/9/1 20:27 
# ide： PyCharm

import execjs


class Fkw:
    def __init__(self, password="123456", exe_function="md5"):
        self.password = password
        self.exe_function = exe_function
        # 1、实例化一个node对象
        self.node = execjs.get()

    def reverse_engineer(self):
        """
        js源码编译和执行
        :return:
        """
        ctx = self.node.compile(open("../static/fke.js", encoding="utf-8").read())
        func_name = "{0}('{1}')".format(self.exe_function, self.password)
        return ctx.eval(func_name)  # 执行获取加密后的pwd


if __name__ == '__main__':
    obj = Fkw()
    pwd = obj.reverse_engineer()
    print(pwd)
